/*
Script: Element.js

Copyright 2005-2007 Netvibes Ltd.
All rights reserved.
*/

if (typeof UWA == "undefined") var UWA = {};
if (typeof UWA.Element == "undefined") UWA.Element = {};
// if (typeof UWA.Element.methods == "undefined") UWA.Element.methods = {};

UWA.extend(UWA.Element, {

  addContent: function(content) {
    if (typeof content == 'string') {
      var node = document.createElement("div");
      node.innerHTML = content;
      return this.appendChild(node);
    }
    return this.appendChild(content);
  },

  appendText: function(text) {
    var node = document.createTextNode(text);
    return this.appendChild(node);
  },

  setText: function(text) {
    this[(typeof this.innerText != 'undefined') ? 'innerText' : 'textContent'] = text;
    return this;
  },

  setHTML: function(html) {
    this.innerHTML = html;
    return this;
  },

  setContent: function(content) {
    if (typeof content == 'string') {
      this.setHTML(content);
    } else if (typeof content == 'object') {
      this.empty();
      this.appendChild(content);
    }
    return this;
  },

  empty: function() {
    this.innerHTML = '';
    return this;
  },
  
  getParent: function(){
		return this.parentNode;
	},

	getChildren: function(){
		return this.childNodes;
	}

});